NIFI-16002 Fix LookupRecord writing to wrong level when parent path is missing#11333
NIFI-16002 Fix LookupRecord writing to wrong level when parent path is missing#11333rakesh-rsky wants to merge 1 commit into
Conversation
9c05a4b to
6ee918b
Compare
…s missing When the configured Result RecordPath contains intermediate nodes that do not yet exist in the record (e.g. /enrichment/value where /enrichment is absent), the RecordPath evaluator returns a missing-child FieldValue with a null value. When updateValue is later called, getParentRecord() skips the null intermediate node and finds the root record instead, writing the result at the wrong nesting level. The fix adds a helper method createMissingParentRecords that walks the FieldValue parent chain and creates an empty MapRecord for each missing intermediate node, setting it on its parent before the actual value is applied. After creating the intermediate Records, incorporateInactiveFields is called so the new fields appear in the active schema and the re-evaluated path resolves them correctly. This fix applies to both scalar lookup values and Record-typed lookup values.
6ee918b to
53bd07d
Compare
exceptionfactory
left a comment
There was a problem hiding this comment.
Thanks for proposing this approach to improve the behavior of LookupRecord @rakesh-rsky. On initial review, I'm not sure whether creating missing intermediate objects is the right approach. The primary concern is that it alters the functional schema of the Record, without reflecting those changes in the Record Schema.
The current behavior does seem problematic, ignoring the intermediate field, and it seems like throwing an error might be an option to consider. There also appears to be some potential performance implications of this approach. Another possibility is to configure this behavior through a new property, but it would be helpful to evaluate the potential issues before moving in that direction.
NIFI-16002 Fix LookupRecord writing to wrong level when parent path is missing
When the configured Result RecordPath contains intermediate nodes that do not yet exist in the record (e.g. /enrichment/value where /enrichment is absent), the RecordPath evaluator returns a missing-child FieldValue with a null value. When updateValue is later called, getParentRecord() skips the null intermediate node and finds the root record instead, writing the result at the wrong nesting level.
The fix adds a helper method createMissingParentRecords that walks the FieldValue parent chain and creates an empty MapRecord for each missing intermediate node, setting it on its parent before the actual value is applied. After creating the intermediate Records, incorporateInactiveFields is called so the new fields appear in the active schema and the re-evaluated path resolves them correctly.
This fix applies to both scalar lookup values and Record-typed lookup values.
Summary
NIFI-16002
Tracking
Please complete the following tracking steps prior to pull request creation.
Issue Tracking
Pull Request Tracking
NIFI-00000NIFI-00000VerifiedstatusPull Request Formatting
mainbranchVerification
Please indicate the verification steps performed prior to pull request creation.
Build
./mvnw clean install -P contrib-checkLicensing
LICENSEandNOTICEfilesDocumentation